//======================================================================
// FileName: pr_seq_gen.h
// Brief:    Common function of generating pseudo-random sequence
// Author:   wenwu
// History of Changes
//        Date|       Author|        Version|        Description
// -----------|-------------|---------------|-------------------
//  2021-08-13|      wenwu  |          0.0.1|    
//======================================================================

#ifndef _PR_SEQ_GEN_h_
#define _PR_SEQ_GEN_h_

#include "Typedef.h" 
#include "MacroDef.h"

#define GETBIT(a,b) (((a)>>(b))&1)

#define NC	1600
#define ST_GOLD_SEQ_FOR_DMRS			1
#define ST_M_SEQ_FOR_DMRS				2
#define ST_GOLD_SEQ_FOR_SCRAM_CODE		3
#define ST_GOLD_SEQ_FOR_SCRAM_INIT	    4
#define ST_GOLD_SEQ_FOR_SCRAM_UPDATE	5


// Generate Gold sequence
void pr_seq_gen(IN uint32 uwCInit, IN uint32 uwSeqLen, OUT char SeqData[]);

// Generate m-sequence x1 and x2
void pr_mseq_gen(IN uint32 uwCInit, IN uint32 uwSeqLen, OUT uint32 *pX1, OUT uint32 *pX2);

// Update scram-sequence x1 and x2
void pr_scramseq_up(IN uint32 uwSeqLen, INOUT uint32 *pX1, INOUT uint32 *pX2);

// Generate initial m-sequence x1 and x2
void pr_seq_init(IN uint32 uwCInit, OUT uint32 *pX1, OUT uint32 *pX2);

// Generate next m-sequence x1 and x2
void pr_seq_next_gen(INOUT uint32 *pX1, INOUT uint32 *pX2);

// Generate pseudo-random sequence(gold sequence) for scrambling code
void pr_seq_gen_scram_code(IN uint32 uwCInit, IN uint32 uwSeqLen, OUT char SeqData[]);

// Generate initial pseudo-random sequence x1 and x2 for scrambling code
void pr_seq_init_for_scram(IN uint32 uwCInit, OUT uint32 *pX1, OUT uint32 *pX2);

// Generate next m-sequence x1 and x2 for scrambling code
void pr_seq_next_gen_for_scram(INOUT uint32 *pX1, INOUT uint32 *pX2);


#endif
